const { ethers, upgrades } = require("hardhat");

async function main() {

    // 获得当前钱包的地址
    const accounts = await ethers.getSigners();
    console.log("address: ", accounts[0].address);
    
    // 获得当前钱包的余额
    const balance = await ethers.provider.getBalance(accounts[0].address);
    // const balance = await accounts[0].getBalance();
    console.log("balance: ", balance);

//    const gas = await ethers.provider.getGasPrice()
   const V1contract = await ethers.getContractFactory("V1");
   console.log("Deploying V1contract...");
   const v1contract = await upgrades.deployProxy(V1contract, [10], {
      initializer: "initialValue",
   }); // 部署的同时初始化数据
   await v1contract.waitForDeployment();
   console.log("V1 Contract deployed to:", v1contract.target);
   console.log("V1 deployed to:", await v1contract.getAddress());
}

main().catch((error) => {
   console.error(error);
   process.exitCode = 1;
 });


// npx hardhat run scripts/deployV1.js --network goerli
// npx hardhat verify --network goerli 0x85e785DCA05b0524E4dd36e4254a4061CDE45Cb5
